.class public Llt/noframe/gpsfarmguide/database/DB;
.super Landroid/database/sqlite/SQLiteOpenHelper;
.source "DB.java"


# static fields
.field public static mInstance:Llt/noframe/gpsfarmguide/database/DB;


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 3

    const-string v0, "allAreas"

    const/4 v1, 0x0

    const/4 v2, 0x3

    .line 62
    invoke-direct {p0, p1, v0, v1, v2}, Landroid/database/sqlite/SQLiteOpenHelper;-><init>(Landroid/content/Context;Ljava/lang/String;Landroid/database/sqlite/SQLiteDatabase$CursorFactory;I)V

    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Ljava/lang/String;)V
    .locals 2

    const/4 v0, 0x0

    const/4 v1, 0x3

    .line 66
    invoke-direct {p0, p1, p2, v0, v1}, Landroid/database/sqlite/SQLiteOpenHelper;-><init>(Landroid/content/Context;Ljava/lang/String;Landroid/database/sqlite/SQLiteDatabase$CursorFactory;I)V

    return-void
.end method

.method private createAreasTable(Landroid/database/sqlite/SQLiteDatabase;)V
    .locals 1

    const-string v0, "CREATE TABLE areas(id INTEGER PRIMARY KEY,name VARCHAR,group_id INTEGER,coordinates VARCHAR,perimeter REAL,area REAL,unique_id VARCHAR)"

    .line 140
    invoke-virtual {p1, v0}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V

    return-void
.end method

.method private createDistancesTable(Landroid/database/sqlite/SQLiteDatabase;)V
    .locals 1

    const-string v0, "CREATE TABLE distances(id INTEGER PRIMARY KEY,name VARCHAR,group_id INTEGER,coordinates VARCHAR,distance REAL,unique_id VARCHAR)"

    .line 155
    invoke-virtual {p1, v0}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V

    return-void
.end method

.method private createGroupsTable(Landroid/database/sqlite/SQLiteDatabase;)V
    .locals 1

    const-string v0, "CREATE TABLE groups(id INTEGER PRIMARY KEY,name VARCHAR)"

    .line 166
    invoke-virtual {p1, v0}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V

    return-void
.end method

.method private createTracksTable(Landroid/database/sqlite/SQLiteDatabase;)V
    .locals 1

    const-string v0, "CREATE TABLE tracks(id INTEGER PRIMARY KEY,field_id INTEGER,name VARCHAR,start_date INTEGER,end_date INTEGER,coordinates VARCHAR,implement_width REAL,navi_coordinates VARCHAR,area REAL,distance REAL,time_wasted REAL)"

    .line 184
    invoke-virtual {p1, v0}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V

    return-void
.end method

.method private cursorToDistance(Landroid/database/Cursor;)Llt/noframe/gpsfarmguide/models/MeasuringModel;
    .locals 3

    .line 501
    new-instance v0, Llt/noframe/gpsfarmguide/models/MeasuringModel;

    new-instance v1, Llt/noframe/gpsfarmguide/models/LineModel;

    invoke-direct {v1}, Llt/noframe/gpsfarmguide/models/LineModel;-><init>()V

    const/4 v2, 0x1

    invoke-direct {v0, v1, v2}, Llt/noframe/gpsfarmguide/models/MeasuringModel;-><init>(Llt/noframe/gpsfarmguide/interfaces/Shape;I)V

    const/4 v1, 0x0

    .line 502
    invoke-interface {p1, v1}, Landroid/database/Cursor;->getInt(I)I

    move-result v1

    invoke-virtual {v0, v1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->setId(I)V

    .line 503
    invoke-interface {p1, v2}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->setName(Ljava/lang/String;)V

    const/4 v1, 0x2

    .line 504
    invoke-interface {p1, v1}, Landroid/database/Cursor;->getInt(I)I

    move-result v1

    invoke-virtual {v0, v1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->setGroup(I)V

    const/4 v1, 0x3

    .line 505
    invoke-interface {p1, v1}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v1

    invoke-static {v1}, Llt/noframe/gpsfarmguide/utils/Utils;->WKT2Points(Ljava/lang/String;)Ljava/util/List;

    move-result-object v1

    invoke-virtual {v0, v1}, Llt/noframe/gpsfarmguide/models/AbstractMeasuringModel;->setPoints(Ljava/util/List;)V

    const/4 v1, 0x5

    .line 506
    invoke-interface {p1, v1}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object p1

    invoke-virtual {v0, p1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->setUniqueId(Ljava/lang/String;)V

    return-object v0
.end method

.method public static getDB()Llt/noframe/gpsfarmguide/database/DB;
    .locals 2

    .line 49
    sget-object v0, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;

    if-nez v0, :cond_0

    .line 50
    new-instance v0, Llt/noframe/gpsfarmguide/database/DB;

    invoke-static {}, Llt/noframe/gpsfarmguide/App;->getContext()Landroid/content/Context;

    move-result-object v1

    invoke-direct {v0, v1}, Llt/noframe/gpsfarmguide/database/DB;-><init>(Landroid/content/Context;)V

    sput-object v0, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;

    .line 52
    :cond_0
    sget-object v0, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;

    return-object v0
.end method

.method private getTableByType(I)Ljava/lang/String;
    .locals 1

    const/4 v0, 0x1

    if-eq p1, v0, :cond_1

    const/4 v0, 0x2

    if-eq p1, v0, :cond_0

    const-string p1, ""

    return-object p1

    :cond_0
    const-string p1, "areas"

    return-object p1

    :cond_1
    const-string p1, "distances"

    return-object p1
.end method

.method private insertDefaultData(Landroid/database/sqlite/SQLiteDatabase;)V
    .locals 3

    .line 191
    new-instance v0, Landroid/content/ContentValues;

    invoke-direct {v0}, Landroid/content/ContentValues;-><init>()V

    .line 192
    invoke-static {}, Llt/noframe/gpsfarmguide/App;->getContext()Landroid/content/Context;

    move-result-object v1

    const v2, 0x7f110159

    invoke-virtual {v1, v2}, Landroid/content/Context;->getString(I)Ljava/lang/String;

    move-result-object v1

    const-string v2, "name"

    invoke-virtual {v0, v2, v1}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V

    const-string v1, "groups"

    const/4 v2, 0x0

    .line 193
    invoke-virtual {p1, v1, v2, v0}, Landroid/database/sqlite/SQLiteDatabase;->insert(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;)J

    return-void
.end method


# virtual methods
.method public declared-synchronized close()V
    .locals 1

    monitor-enter p0

    .line 57
    :try_start_0
    invoke-super {p0}, Landroid/database/sqlite/SQLiteOpenHelper;->close()V

    const/4 v0, 0x0

    .line 58
    sput-object v0, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 59
    monitor-exit p0

    return-void

    :catchall_0
    move-exception v0

    monitor-exit p0

    throw v0
.end method

.method public cursor2AreaList(Landroid/database/Cursor;)Llt/noframe/gpsfarmguide/models/MeasureListModel;
    .locals 3

    .line 681
    new-instance v0, Llt/noframe/gpsfarmguide/models/MeasureListModel;

    invoke-direct {v0}, Llt/noframe/gpsfarmguide/models/MeasureListModel;-><init>()V

    const/4 v1, 0x2

    .line 682
    invoke-virtual {v0, v1}, Llt/noframe/gpsfarmguide/models/MeasureListModel;->setType(I)V

    const/4 v2, 0x0

    .line 683
    invoke-interface {p1, v2}, Landroid/database/Cursor;->getInt(I)I

    move-result v2

    invoke-virtual {v0, v2}, Llt/noframe/gpsfarmguide/models/MeasureListModel;->setId(I)V

    const/4 v2, 0x1

    .line 684
    invoke-interface {p1, v2}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v0, v2}, Llt/noframe/gpsfarmguide/models/MeasureListModel;->setName(Ljava/lang/String;)V

    .line 685
    invoke-interface {p1, v1}, Landroid/database/Cursor;->getInt(I)I

    move-result v2

    invoke-virtual {p0, v2}, Llt/noframe/gpsfarmguide/database/DB;->getGroupName(I)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v0, v2}, Llt/noframe/gpsfarmguide/models/MeasureListModel;->setGroup(Ljava/lang/String;)V

    .line 686
    invoke-interface {p1, v1}, Landroid/database/Cursor;->getInt(I)I

    move-result v1

    invoke-virtual {v0, v1}, Llt/noframe/gpsfarmguide/models/MeasureListModel;->setGroupId(I)V

    const/4 v1, 0x3

    .line 687
    invoke-interface {p1, v1}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v1

    invoke-static {v1}, Llt/noframe/gpsfarmguide/utils/Utils;->WKT2Points(Ljava/lang/String;)Ljava/util/List;

    move-result-object v1

    .line 688
    invoke-virtual {v0, v1}, Llt/noframe/gpsfarmguide/models/MeasureListModel;->setPoints(Ljava/util/List;)V

    const/4 v1, 0x4

    .line 689
    invoke-interface {p1, v1}, Landroid/database/Cursor;->getDouble(I)D

    move-result-wide v1

    invoke-virtual {v0, v1, v2}, Llt/noframe/gpsfarmguide/models/MeasureListModel;->setParameter1(D)V

    const/4 v1, 0x5

    .line 690
    invoke-interface {p1, v1}, Landroid/database/Cursor;->getDouble(I)D

    move-result-wide v1

    invoke-virtual {v0, v1, v2}, Llt/noframe/gpsfarmguide/models/MeasureListModel;->setParameter2(D)V

    const/4 v1, 0x6

    .line 691
    invoke-interface {p1, v1}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object p1

    invoke-virtual {v0, p1}, Llt/noframe/gpsfarmguide/models/MeasureListModel;->setUniqueId(Ljava/lang/String;)V

    return-object v0
.end method

.method public cursor2DistanceList(Landroid/database/Cursor;)Llt/noframe/gpsfarmguide/models/MeasureListModel;
    .locals 3

    .line 670
    new-instance v0, Llt/noframe/gpsfarmguide/models/MeasureListModel;

    invoke-direct {v0}, Llt/noframe/gpsfarmguide/models/MeasureListModel;-><init>()V

    const/4 v1, 0x1

    .line 671
    invoke-virtual {v0, v1}, Llt/noframe/gpsfarmguide/models/MeasureListModel;->setType(I)V

    const/4 v2, 0x0

    .line 672
    invoke-interface {p1, v2}, Landroid/database/Cursor;->getInt(I)I

    move-result v2

    invoke-virtual {v0, v2}, Llt/noframe/gpsfarmguide/models/MeasureListModel;->setId(I)V

    .line 673
    invoke-interface {p1, v1}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Llt/noframe/gpsfarmguide/models/MeasureListModel;->setName(Ljava/lang/String;)V

    const/4 v1, 0x2

    .line 674
    invoke-interface {p1, v1}, Landroid/database/Cursor;->getInt(I)I

    move-result v1

    invoke-virtual {p0, v1}, Llt/noframe/gpsfarmguide/database/DB;->getGroupName(I)Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Llt/noframe/gpsfarmguide/models/MeasureListModel;->setGroup(Ljava/lang/String;)V

    const/4 v1, 0x4

    .line 675
    invoke-interface {p1, v1}, Landroid/database/Cursor;->getDouble(I)D

    move-result-wide v1

    invoke-virtual {v0, v1, v2}, Llt/noframe/gpsfarmguide/models/MeasureListModel;->setParameter1(D)V

    return-object v0
.end method

.method public cursor2Group(Landroid/database/Cursor;)Llt/noframe/gpsfarmguide/models/GroupModel;
    .locals 2

    .line 584
    new-instance v0, Llt/noframe/gpsfarmguide/models/GroupModel;

    invoke-direct {v0}, Llt/noframe/gpsfarmguide/models/GroupModel;-><init>()V

    const/4 v1, 0x0

    .line 585
    invoke-interface {p1, v1}, Landroid/database/Cursor;->getInt(I)I

    move-result v1

    invoke-virtual {v0, v1}, Llt/noframe/gpsfarmguide/models/GroupModel;->setId(I)V

    const/4 v1, 0x1

    .line 586
    invoke-interface {p1, v1}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object p1

    invoke-virtual {v0, p1}, Llt/noframe/gpsfarmguide/models/GroupModel;->setName(Ljava/lang/String;)V

    return-object v0
.end method

.method public cursorToArea(Landroid/database/Cursor;)Llt/noframe/gpsfarmguide/models/MeasuringModel;
    .locals 4
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .line 483
    new-instance v0, Llt/noframe/gpsfarmguide/models/MeasuringModel;

    new-instance v1, Llt/noframe/gpsfarmguide/models/PolygonModel;

    invoke-direct {v1}, Llt/noframe/gpsfarmguide/models/PolygonModel;-><init>()V

    const/4 v2, 0x2

    invoke-direct {v0, v1, v2}, Llt/noframe/gpsfarmguide/models/MeasuringModel;-><init>(Llt/noframe/gpsfarmguide/interfaces/Shape;I)V

    const/4 v1, 0x0

    .line 484
    invoke-interface {p1, v1}, Landroid/database/Cursor;->getInt(I)I

    move-result v1

    invoke-virtual {v0, v1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->setId(I)V

    const/4 v1, 0x1

    .line 485
    invoke-interface {p1, v1}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v0, v3}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->setName(Ljava/lang/String;)V

    .line 486
    invoke-interface {p1, v2}, Landroid/database/Cursor;->getInt(I)I

    move-result v2

    invoke-virtual {v0, v2}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->setGroup(I)V

    const/4 v2, 0x3

    .line 487
    invoke-interface {p1, v2}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v2

    invoke-static {v2}, Llt/noframe/gpsfarmguide/utils/Utils;->WKT2Points(Ljava/lang/String;)Ljava/util/List;

    move-result-object v2

    .line 488
    invoke-interface {v2}, Ljava/util/List;->size()I

    move-result v3

    sub-int/2addr v3, v1

    invoke-interface {v2, v3}, Ljava/util/List;->remove(I)Ljava/lang/Object;

    .line 489
    invoke-virtual {v0, v2}, Llt/noframe/gpsfarmguide/models/AbstractMeasuringModel;->setPoints(Ljava/util/List;)V

    const/4 v1, 0x6

    .line 490
    invoke-interface {p1, v1}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object p1

    invoke-virtual {v0, p1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->setUniqueId(Ljava/lang/String;)V

    return-object v0
.end method

.method public deleteArea(I)Z
    .locals 6

    .line 283
    sget-object v0, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;

    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteOpenHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    const/4 v1, 0x1

    .line 285
    new-array v2, v1, [Ljava/lang/String;

    invoke-static {p1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v3

    const/4 v4, 0x0

    aput-object v3, v2, v4

    const-string v3, "tracks"

    const-string v5, "field_id=?"

    invoke-virtual {v0, v3, v5, v2}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I

    .line 286
    new-array v2, v1, [Ljava/lang/String;

    invoke-static {p1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object p1

    aput-object p1, v2, v4

    const-string p1, "areas"

    const-string v3, "id=?"

    invoke-virtual {v0, p1, v3, v2}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I

    move-result p1

    if-eqz p1, :cond_0

    goto :goto_0

    :cond_0
    const/4 v1, 0x0

    :goto_0
    return v1
.end method

.method public deleteGroup(I)Z
    .locals 5

    .line 311
    sget-object v0, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;

    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteOpenHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    const/4 v1, 0x1

    .line 312
    new-array v2, v1, [Ljava/lang/String;

    invoke-static {p1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object p1

    const/4 v3, 0x0

    aput-object p1, v2, v3

    const-string p1, "groups"

    const-string v4, "id=?"

    invoke-virtual {v0, p1, v4, v2}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I

    move-result p1

    if-eqz p1, :cond_0

    goto :goto_0

    :cond_0
    const/4 v1, 0x0

    :goto_0
    return v1
.end method

.method public deleteMeasure(Llt/noframe/gpsfarmguide/models/MeasuringModel;)Z
    .locals 7

    .line 264
    sget-object v0, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;

    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteOpenHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 265
    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->getMeasuringType()I

    move-result v1

    invoke-direct {p0, v1}, Llt/noframe/gpsfarmguide/database/DB;->getTableByType(I)Ljava/lang/String;

    move-result-object v1

    const-string v2, ""

    .line 266
    invoke-virtual {v1, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    const/4 v3, 0x0

    if-nez v2, :cond_1

    const/4 v2, 0x1

    .line 267
    new-array v4, v2, [Ljava/lang/String;

    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->getId()I

    move-result v5

    invoke-static {v5}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v5

    aput-object v5, v4, v3

    const-string v5, "tracks"

    const-string v6, "field_id=?"

    invoke-virtual {v0, v5, v6, v4}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I

    .line 268
    new-array v4, v2, [Ljava/lang/String;

    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->getId()I

    move-result p1

    invoke-static {p1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object p1

    aput-object p1, v4, v3

    const-string p1, "id=?"

    invoke-virtual {v0, v1, p1, v4}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I

    move-result p1

    if-eqz p1, :cond_0

    goto :goto_0

    :cond_0
    const/4 v2, 0x0

    :goto_0
    return v2

    :cond_1
    const-string p1, "DATABASE"

    const-string v0, "ERROR DELETING MEASURE"

    .line 271
    invoke-static {p1, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    return v3
.end method

.method public getArea(I)Llt/noframe/gpsfarmguide/models/MeasuringModel;
    .locals 9

    .line 432
    sget-object v0, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;

    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteOpenHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    const/4 v0, 0x1

    .line 434
    new-array v5, v0, [Ljava/lang/String;

    invoke-static {p1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object p1

    const/4 v0, 0x0

    aput-object p1, v5, v0

    const-string v2, "areas"

    const/4 v3, 0x0

    const-string v4, "id =?"

    const/4 v6, 0x0

    const/4 v7, 0x0

    const/4 v8, 0x0

    invoke-virtual/range {v1 .. v8}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object p1

    .line 437
    :try_start_0
    invoke-interface {p1}, Landroid/database/Cursor;->moveToFirst()Z

    .line 438
    invoke-interface {p1}, Landroid/database/Cursor;->isAfterLast()Z

    move-result v0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    const/4 v1, 0x0

    if-nez v0, :cond_0

    .line 440
    :try_start_1
    invoke-virtual {p0, p1}, Llt/noframe/gpsfarmguide/database/DB;->cursorToArea(Landroid/database/Cursor;)Llt/noframe/gpsfarmguide/models/MeasuringModel;

    move-result-object v1
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_0

    :catch_0
    move-exception v0

    .line 442
    :try_start_2
    invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V

    .line 444
    :goto_0
    invoke-interface {p1}, Landroid/database/Cursor;->moveToNext()Z
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    .line 447
    :cond_0
    invoke-interface {p1}, Landroid/database/Cursor;->close()V

    return-object v1

    :catchall_0
    move-exception v0

    invoke-interface {p1}, Landroid/database/Cursor;->close()V

    throw v0
.end method

.method public getAreas()Ljava/util/List;
    .locals 9
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/List<",
            "Llt/noframe/gpsfarmguide/models/MeasuringModel;",
            ">;"
        }
    .end annotation

    .line 371
    sget-object v0, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;

    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteOpenHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    .line 372
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    const-string v2, "areas"

    const/4 v3, 0x0

    const/4 v4, 0x0

    const/4 v5, 0x0

    const/4 v6, 0x0

    const/4 v7, 0x0

    const/4 v8, 0x0

    .line 373
    invoke-virtual/range {v1 .. v8}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v1

    .line 376
    :try_start_0
    invoke-interface {v1}, Landroid/database/Cursor;->moveToFirst()Z

    .line 377
    :goto_0
    invoke-interface {v1}, Landroid/database/Cursor;->isAfterLast()Z

    move-result v2
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    if-nez v2, :cond_0

    .line 379
    :try_start_1
    invoke-virtual {p0, v1}, Llt/noframe/gpsfarmguide/database/DB;->cursorToArea(Landroid/database/Cursor;)Llt/noframe/gpsfarmguide/models/MeasuringModel;

    move-result-object v2

    .line 380
    invoke-interface {v0, v2}, Ljava/util/List;->add(Ljava/lang/Object;)Z
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_1

    :catch_0
    move-exception v2

    .line 382
    :try_start_2
    invoke-virtual {v2}, Ljava/lang/Exception;->printStackTrace()V

    .line 384
    :goto_1
    invoke-interface {v1}, Landroid/database/Cursor;->moveToNext()Z
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    goto :goto_0

    .line 387
    :cond_0
    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    return-object v0

    :catchall_0
    move-exception v0

    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    goto :goto_3

    :goto_2
    throw v0

    :goto_3
    goto :goto_2
.end method

.method public getAreasCursor(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;
    .locals 9

    .line 399
    sget-object v0, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;

    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteOpenHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    const-string v2, "areas"

    const/4 v3, 0x0

    const/4 v6, 0x0

    const/4 v7, 0x0

    const/4 v8, 0x0

    move-object v4, p1

    move-object v5, p2

    .line 400
    invoke-virtual/range {v1 .. v8}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object p1

    return-object p1
.end method

.method public getDistances()Ljava/util/List;
    .locals 9
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/List<",
            "Llt/noframe/gpsfarmguide/models/MeasuringModel;",
            ">;"
        }
    .end annotation

    .line 459
    sget-object v0, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;

    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteOpenHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    .line 460
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    const-string v2, "distances"

    const/4 v3, 0x0

    const/4 v4, 0x0

    const/4 v5, 0x0

    const/4 v6, 0x0

    const/4 v7, 0x0

    const/4 v8, 0x0

    .line 461
    invoke-virtual/range {v1 .. v8}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v1

    .line 464
    :try_start_0
    invoke-interface {v1}, Landroid/database/Cursor;->moveToFirst()Z

    .line 465
    :goto_0
    invoke-interface {v1}, Landroid/database/Cursor;->isAfterLast()Z

    move-result v2

    if-nez v2, :cond_0

    .line 466
    invoke-direct {p0, v1}, Llt/noframe/gpsfarmguide/database/DB;->cursorToDistance(Landroid/database/Cursor;)Llt/noframe/gpsfarmguide/models/MeasuringModel;

    move-result-object v2

    .line 467
    invoke-interface {v0, v2}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 468
    invoke-interface {v1}, Landroid/database/Cursor;->moveToNext()Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    goto :goto_0

    .line 471
    :cond_0
    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    return-object v0

    :catchall_0
    move-exception v0

    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    goto :goto_2

    :goto_1
    throw v0

    :goto_2
    goto :goto_1
.end method

.method public getGroupName(I)Ljava/lang/String;
    .locals 10

    .line 539
    sget-object v0, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;

    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteOpenHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    const/4 v0, 0x1

    .line 541
    new-array v3, v0, [Ljava/lang/String;

    const/4 v9, 0x0

    const-string v2, "name"

    aput-object v2, v3, v9

    new-array v5, v0, [Ljava/lang/String;

    .line 542
    invoke-static {p1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object p1

    aput-object p1, v5, v9

    const-string v2, "groups"

    const-string v4, "id=?"

    const/4 v6, 0x0

    const/4 v7, 0x0

    const/4 v8, 0x0

    .line 541
    invoke-virtual/range {v1 .. v8}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object p1

    .line 544
    :try_start_0
    invoke-interface {p1}, Landroid/database/Cursor;->moveToFirst()Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    const-string v0, ""

    .line 545
    :goto_0
    :try_start_1
    invoke-interface {p1}, Landroid/database/Cursor;->isAfterLast()Z

    move-result v1

    if-nez v1, :cond_0

    .line 546
    invoke-interface {p1, v9}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v0

    .line 547
    invoke-interface {p1}, Landroid/database/Cursor;->moveToNext()Z
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_0

    .line 550
    :cond_0
    invoke-interface {p1}, Landroid/database/Cursor;->close()V

    return-object v0

    :catchall_0
    move-exception v0

    invoke-interface {p1}, Landroid/database/Cursor;->close()V

    goto :goto_2

    :goto_1
    throw v0

    :goto_2
    goto :goto_1
.end method

.method public getGroups()Ljava/util/List;
    .locals 9
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/List<",
            "Llt/noframe/gpsfarmguide/models/GroupModel;",
            ">;"
        }
    .end annotation

    .line 517
    sget-object v0, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;

    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteOpenHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    .line 518
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    const-string v2, "groups"

    const/4 v3, 0x0

    const/4 v4, 0x0

    const/4 v5, 0x0

    const/4 v6, 0x0

    const/4 v7, 0x0

    const/4 v8, 0x0

    .line 519
    invoke-virtual/range {v1 .. v8}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v1

    .line 522
    :try_start_0
    invoke-interface {v1}, Landroid/database/Cursor;->moveToFirst()Z

    .line 523
    :goto_0
    invoke-interface {v1}, Landroid/database/Cursor;->isAfterLast()Z

    move-result v2

    if-nez v2, :cond_0

    .line 524
    invoke-virtual {p0, v1}, Llt/noframe/gpsfarmguide/database/DB;->cursor2Group(Landroid/database/Cursor;)Llt/noframe/gpsfarmguide/models/GroupModel;

    move-result-object v2

    invoke-interface {v0, v2}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 525
    invoke-interface {v1}, Landroid/database/Cursor;->moveToNext()Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    goto :goto_0

    .line 528
    :cond_0
    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    return-object v0

    :catchall_0
    move-exception v0

    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    goto :goto_2

    :goto_1
    throw v0

    :goto_2
    goto :goto_1
.end method

.method public getGroupsCursor(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;
    .locals 9

    .line 411
    sget-object v0, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;

    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteOpenHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    const-string v2, "groups"

    const/4 v3, 0x0

    const/4 v6, 0x0

    const/4 v7, 0x0

    const/4 v8, 0x0

    move-object v4, p1

    move-object v5, p2

    .line 412
    invoke-virtual/range {v1 .. v8}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object p1

    return-object p1
.end method

.method public getLastInsertedId(I)I
    .locals 4

    .line 597
    sget-object v0, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;

    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteOpenHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 598
    invoke-direct {p0, p1}, Llt/noframe/gpsfarmguide/database/DB;->getTableByType(I)Ljava/lang/String;

    move-result-object p1

    const-string v1, ""

    .line 600
    invoke-virtual {p1, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v1

    const/4 v2, 0x0

    if-nez v1, :cond_0

    .line 601
    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v3, "SELECT MAX(id) FROM "

    invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p1

    const/4 v1, 0x0

    invoke-virtual {v0, p1, v1}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object p1

    .line 604
    :try_start_0
    invoke-interface {p1}, Landroid/database/Cursor;->moveToFirst()Z

    .line 605
    invoke-interface {p1, v2}, Landroid/database/Cursor;->getInt(I)I

    move-result v2
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 607
    invoke-interface {p1}, Landroid/database/Cursor;->close()V

    goto :goto_0

    :catchall_0
    move-exception v0

    invoke-interface {p1}, Landroid/database/Cursor;->close()V

    throw v0

    :cond_0
    const-string p1, "DATABASE"

    const-string v0, "ERROR GETTING LAST ID"

    .line 610
    invoke-static {p1, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    :goto_0
    return v2
.end method

.method public getMeasuresForList(II)Ljava/util/List;
    .locals 12
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(II)",
            "Ljava/util/List<",
            "Llt/noframe/gpsfarmguide/models/MeasureListModel;",
            ">;"
        }
    .end annotation

    .line 639
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    .line 640
    sget-object v1, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;

    invoke-virtual {v1}, Landroid/database/sqlite/SQLiteOpenHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v2

    .line 641
    invoke-direct {p0, p1}, Llt/noframe/gpsfarmguide/database/DB;->getTableByType(I)Ljava/lang/String;

    move-result-object v3

    const-string v1, ""

    .line 642
    invoke-virtual {v3, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v1

    const-string v10, "DATABASE"

    if-nez v1, :cond_6

    const/4 v1, 0x0

    const/4 v11, 0x1

    if-nez p2, :cond_0

    const/4 v4, 0x0

    const/4 v5, 0x0

    const/4 v6, 0x0

    const/4 v7, 0x0

    const/4 v8, 0x0

    const-string v9, "group_id ASC"

    .line 645
    invoke-virtual/range {v2 .. v9}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v1

    goto :goto_0

    :cond_0
    if-lez p2, :cond_1

    const/4 v4, 0x0

    .line 647
    new-array v6, v11, [Ljava/lang/String;

    const/4 v1, 0x0

    .line 648
    invoke-static {p2}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object p2

    aput-object p2, v6, v1

    const/4 v7, 0x0

    const/4 v8, 0x0

    const-string v5, "group_id=?"

    const-string v9, "group_id ASC"

    .line 647
    invoke-virtual/range {v2 .. v9}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v1

    :cond_1
    :goto_0
    if-eqz v1, :cond_5

    .line 651
    :try_start_0
    invoke-interface {v1}, Landroid/database/Cursor;->moveToFirst()Z

    .line 652
    :goto_1
    invoke-interface {v1}, Landroid/database/Cursor;->isAfterLast()Z

    move-result p2

    if-nez p2, :cond_4

    if-ne p1, v11, :cond_2

    .line 654
    invoke-virtual {p0, v1}, Llt/noframe/gpsfarmguide/database/DB;->cursor2DistanceList(Landroid/database/Cursor;)Llt/noframe/gpsfarmguide/models/MeasureListModel;

    move-result-object p2

    invoke-interface {v0, p2}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    goto :goto_2

    :cond_2
    const/4 p2, 0x2

    if-ne p1, p2, :cond_3

    .line 656
    invoke-virtual {p0, v1}, Llt/noframe/gpsfarmguide/database/DB;->cursor2AreaList(Landroid/database/Cursor;)Llt/noframe/gpsfarmguide/models/MeasureListModel;

    move-result-object p2

    invoke-interface {v0, p2}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 657
    :cond_3
    :goto_2
    invoke-interface {v1}, Landroid/database/Cursor;->moveToNext()Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    goto :goto_1

    .line 660
    :cond_4
    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    goto :goto_3

    :catchall_0
    move-exception p1

    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    throw p1

    :cond_5
    const-string p1, "ERROR GETTING MEASURES FOR LIST. BAD GROUP SPECIFIED"

    .line 663
    invoke-static {v10, p1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_3

    :cond_6
    const-string p1, "ERROR GETTING MEASURES FOR LIST. NO TYPE SPECIFIED"

    .line 665
    invoke-static {v10, p1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    :goto_3
    return-object v0
.end method

.method public getTracksCursor(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;
    .locals 9

    .line 420
    sget-object v0, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;

    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteOpenHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    const-string v2, "tracks"

    const/4 v3, 0x0

    const/4 v6, 0x0

    const/4 v7, 0x0

    const/4 v8, 0x0

    move-object v4, p1

    move-object v5, p2

    .line 421
    invoke-virtual/range {v1 .. v8}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object p1

    return-object p1
.end method

.method public insertArea(Llt/noframe/gpsfarmguide/models/MeasuringModel;)J
    .locals 4

    .line 232
    sget-object v0, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;

    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteOpenHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 233
    new-instance v1, Landroid/content/ContentValues;

    invoke-direct {v1}, Landroid/content/ContentValues;-><init>()V

    .line 234
    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->getName()Ljava/lang/String;

    move-result-object v2

    const-string v3, "name"

    invoke-virtual {v1, v3, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V

    .line 235
    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->getGroup()I

    move-result v2

    invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v2

    const-string v3, "group_id"

    invoke-virtual {v1, v3, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Integer;)V

    .line 236
    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/AbstractMeasuringModel;->getWkt()Ljava/lang/String;

    move-result-object v2

    const-string v3, "coordinates"

    invoke-virtual {v1, v3, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V

    .line 237
    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/AbstractMeasuringModel;->getPoints()Ljava/util/List;

    move-result-object v2

    invoke-static {v2}, Llt/noframe/gpsfarmguide/utils/Mathematics;->calculatePerimeter(Ljava/util/List;)D

    move-result-wide v2

    invoke-static {v2, v3}, Llt/noframe/gpsfarmguide/utils/Utils;->smartRounding(D)D

    move-result-wide v2

    invoke-static {v2, v3}, Ljava/lang/Double;->valueOf(D)Ljava/lang/Double;

    move-result-object v2

    const-string v3, "perimeter"

    invoke-virtual {v1, v3, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Double;)V

    .line 238
    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/AbstractMeasuringModel;->getPoints()Ljava/util/List;

    move-result-object v2

    invoke-static {v2}, Llt/noframe/gpsfarmguide/utils/Mathematics;->calculateArea(Ljava/util/List;)D

    move-result-wide v2

    invoke-static {v2, v3}, Llt/noframe/gpsfarmguide/utils/Utils;->smartRounding(D)D

    move-result-wide v2

    invoke-static {v2, v3}, Ljava/lang/Double;->valueOf(D)Ljava/lang/Double;

    move-result-object v2

    const-string v3, "area"

    invoke-virtual {v1, v3, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Double;)V

    .line 239
    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->getUniqueId()Ljava/lang/String;

    move-result-object p1

    const-string v2, "unique_id"

    invoke-virtual {v1, v2, p1}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V

    const-string p1, "areas"

    const/4 v2, 0x0

    .line 240
    invoke-virtual {v0, p1, v2, v1}, Landroid/database/sqlite/SQLiteDatabase;->insert(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;)J

    move-result-wide v0

    return-wide v0
.end method

.method public isGroupExists(Ljava/lang/String;)Z
    .locals 10

    .line 322
    sget-object v0, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;

    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteOpenHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    const/4 v0, 0x1

    .line 323
    new-array v3, v0, [Ljava/lang/String;

    const/4 v9, 0x0

    const-string v2, "name"

    aput-object v2, v3, v9

    new-array v5, v0, [Ljava/lang/String;

    aput-object p1, v5, v9

    const-string v2, "groups"

    const-string v4, "name=?"

    const/4 v6, 0x0

    const/4 v7, 0x0

    const/4 v8, 0x0

    invoke-virtual/range {v1 .. v8}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v1

    .line 326
    :try_start_0
    invoke-interface {v1}, Landroid/database/Cursor;->moveToFirst()Z

    .line 327
    :goto_0
    invoke-interface {v1}, Landroid/database/Cursor;->isAfterLast()Z

    move-result v2

    if-nez v2, :cond_1

    .line 328
    invoke-interface {v1, v9}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {p1, v2}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v2
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    if-eqz v2, :cond_0

    .line 333
    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    return v0

    .line 330
    :cond_0
    :try_start_1
    invoke-interface {v1}, Landroid/database/Cursor;->moveToNext()Z
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_0

    .line 333
    :cond_1
    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    return v9

    :catchall_0
    move-exception p1

    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    goto :goto_2

    :goto_1
    throw p1

    :goto_2
    goto :goto_1
.end method

.method public onCreate(Landroid/database/sqlite/SQLiteDatabase;)V
    .locals 0

    .line 71
    invoke-direct {p0, p1}, Llt/noframe/gpsfarmguide/database/DB;->createAreasTable(Landroid/database/sqlite/SQLiteDatabase;)V

    .line 72
    invoke-direct {p0, p1}, Llt/noframe/gpsfarmguide/database/DB;->createDistancesTable(Landroid/database/sqlite/SQLiteDatabase;)V

    .line 73
    invoke-direct {p0, p1}, Llt/noframe/gpsfarmguide/database/DB;->createGroupsTable(Landroid/database/sqlite/SQLiteDatabase;)V

    .line 74
    invoke-direct {p0, p1}, Llt/noframe/gpsfarmguide/database/DB;->createTracksTable(Landroid/database/sqlite/SQLiteDatabase;)V

    .line 75
    invoke-direct {p0, p1}, Llt/noframe/gpsfarmguide/database/DB;->insertDefaultData(Landroid/database/sqlite/SQLiteDatabase;)V

    return-void
.end method

.method public onUpgrade(Landroid/database/sqlite/SQLiteDatabase;II)V
    .locals 0

    const/4 p3, 0x1

    if-eq p2, p3, :cond_0

    const/4 p3, 0x2

    if-eq p2, p3, :cond_1

    goto :goto_0

    :cond_0
    const-string p2, "ALTER TABLE tracks ADD COLUMN navi_coordinates VARCHAR;"

    .line 82
    invoke-virtual {p1, p2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V

    const-string p2, "ALTER TABLE tracks ADD COLUMN area REAL;"

    .line 83
    invoke-virtual {p1, p2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V

    const-string p2, "ALTER TABLE tracks ADD COLUMN distance REAL;"

    .line 84
    invoke-virtual {p1, p2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V

    :cond_1
    const-string p2, "ALTER TABLE tracks ADD COLUMN time_wasted REAL;"

    .line 86
    invoke-virtual {p1, p2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V

    :goto_0
    return-void
.end method

.method public saveGroup(Llt/noframe/gpsfarmguide/models/GroupModel;)V
    .locals 4

    .line 294
    sget-object v0, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;

    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteOpenHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 295
    new-instance v1, Landroid/content/ContentValues;

    invoke-direct {v1}, Landroid/content/ContentValues;-><init>()V

    .line 296
    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/GroupModel;->getName()Ljava/lang/String;

    move-result-object v2

    const-string v3, "name"

    invoke-virtual {v1, v3, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V

    const/4 v2, 0x1

    .line 298
    new-array v2, v2, [Ljava/lang/String;

    .line 299
    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/GroupModel;->getId()I

    move-result p1

    invoke-static {p1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object p1

    const/4 v3, 0x0

    aput-object p1, v2, v3

    const-string p1, "groups"

    const-string v3, "id=?"

    .line 298
    invoke-virtual {v0, p1, v1, v3, v2}, Landroid/database/sqlite/SQLiteDatabase;->update(Ljava/lang/String;Landroid/content/ContentValues;Ljava/lang/String;[Ljava/lang/String;)I

    move-result v2

    if-nez v2, :cond_0

    const/4 v2, 0x0

    .line 301
    invoke-virtual {v0, p1, v2, v1}, Landroid/database/sqlite/SQLiteDatabase;->insert(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;)J

    :cond_0
    return-void
.end method

.method public saveMeasure(Llt/noframe/gpsfarmguide/models/MeasuringModel;)V
    .locals 6

    .line 202
    sget-object v0, Llt/noframe/gpsfarmguide/database/DB;->mInstance:Llt/noframe/gpsfarmguide/database/DB;

    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteOpenHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 203
    new-instance v1, Landroid/content/ContentValues;

    invoke-direct {v1}, Landroid/content/ContentValues;-><init>()V

    .line 204
    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->getName()Ljava/lang/String;

    move-result-object v2

    const-string v3, "name"

    invoke-virtual {v1, v3, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V

    .line 205
    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->getGroup()I

    move-result v2

    invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v2

    const-string v3, "group_id"

    invoke-virtual {v1, v3, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Integer;)V

    .line 206
    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/AbstractMeasuringModel;->getWkt()Ljava/lang/String;

    move-result-object v2

    const-string v3, "coordinates"

    invoke-virtual {v1, v3, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V

    .line 207
    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/AbstractMeasuringModel;->getType()I

    move-result v2

    const/4 v3, 0x1

    if-ne v2, v3, :cond_0

    .line 208
    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/AbstractMeasuringModel;->getPoints()Ljava/util/List;

    move-result-object v2

    invoke-static {v2}, Llt/noframe/gpsfarmguide/utils/Mathematics;->calculateDistance(Ljava/util/List;)D

    move-result-wide v4

    invoke-static {v4, v5}, Llt/noframe/gpsfarmguide/utils/Utils;->smartRounding(D)D

    move-result-wide v4

    invoke-static {v4, v5}, Ljava/lang/Double;->valueOf(D)Ljava/lang/Double;

    move-result-object v2

    const-string v4, "distance"

    invoke-virtual {v1, v4, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Double;)V

    goto :goto_0

    .line 209
    :cond_0
    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/AbstractMeasuringModel;->getType()I

    move-result v2

    const/4 v4, 0x2

    if-ne v2, v4, :cond_1

    .line 210
    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/AbstractMeasuringModel;->getPoints()Ljava/util/List;

    move-result-object v2

    invoke-static {v2}, Llt/noframe/gpsfarmguide/utils/Mathematics;->calculatePerimeter(Ljava/util/List;)D

    move-result-wide v4

    invoke-static {v4, v5}, Llt/noframe/gpsfarmguide/utils/Utils;->smartRounding(D)D

    move-result-wide v4

    invoke-static {v4, v5}, Ljava/lang/Double;->valueOf(D)Ljava/lang/Double;

    move-result-object v2

    const-string v4, "perimeter"

    invoke-virtual {v1, v4, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Double;)V

    .line 211
    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/AbstractMeasuringModel;->getPoints()Ljava/util/List;

    move-result-object v2

    invoke-static {v2}, Llt/noframe/gpsfarmguide/utils/Mathematics;->calculateArea(Ljava/util/List;)D

    move-result-wide v4

    invoke-static {v4, v5}, Llt/noframe/gpsfarmguide/utils/Utils;->smartRounding(D)D

    move-result-wide v4

    invoke-static {v4, v5}, Ljava/lang/Double;->valueOf(D)Ljava/lang/Double;

    move-result-object v2

    const-string v4, "area"

    invoke-virtual {v1, v4, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Double;)V

    .line 213
    :cond_1
    :goto_0
    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->getUniqueId()Ljava/lang/String;

    move-result-object v2

    const-string v4, "unique_id"

    invoke-virtual {v1, v4, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V

    .line 214
    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->getMeasuringType()I

    move-result v2

    invoke-direct {p0, v2}, Llt/noframe/gpsfarmguide/database/DB;->getTableByType(I)Ljava/lang/String;

    move-result-object v2

    const-string v4, ""

    .line 215
    invoke-virtual {v2, v4}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v4

    if-nez v4, :cond_2

    .line 217
    new-array v3, v3, [Ljava/lang/String;

    const/4 v4, 0x0

    .line 218
    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->getId()I

    move-result p1

    invoke-static {p1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object p1

    aput-object p1, v3, v4

    const-string p1, "id=?"

    .line 217
    invoke-virtual {v0, v2, v1, p1, v3}, Landroid/database/sqlite/SQLiteDatabase;->update(Ljava/lang/String;Landroid/content/ContentValues;Ljava/lang/String;[Ljava/lang/String;)I

    move-result p1

    if-nez p1, :cond_3

    const/4 p1, 0x0

    .line 220
    invoke-virtual {v0, v2, p1, v1}, Landroid/database/sqlite/SQLiteDatabase;->insert(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;)J

    goto :goto_1

    :cond_2
    const-string p1, "DATABASE"

    const-string v0, "ERROR INSERTING MEASURE"

    .line 222
    invoke-static {p1, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    :cond_3
    :goto_1
    return-void
.end method

.method public validateDb()Z
    .locals 13

    const-string v0, "coordinates"

    const-string v1, "group_id"

    const-string v2, "name"

    const-string v3, "id"

    .line 93
    invoke-virtual {p0}, Landroid/database/sqlite/SQLiteOpenHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v12

    :try_start_0
    const-string v5, "areas"

    const/4 v6, 0x0

    const/4 v7, 0x0

    const/4 v8, 0x0

    const/4 v9, 0x0

    const/4 v10, 0x0

    const/4 v11, 0x0

    move-object v4, v12

    .line 95
    invoke-virtual/range {v4 .. v11}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v4

    .line 96
    invoke-interface {v4, v3}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    .line 97
    invoke-interface {v4, v2}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    .line 98
    invoke-interface {v4, v1}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    .line 99
    invoke-interface {v4, v0}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    const-string v5, "perimeter"

    .line 100
    invoke-interface {v4, v5}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    const-string v5, "area"

    .line 101
    invoke-interface {v4, v5}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    .line 102
    invoke-interface {v4}, Landroid/database/Cursor;->close()V

    const-string v5, "distances"

    const/4 v6, 0x0

    const/4 v7, 0x0

    const/4 v8, 0x0

    const/4 v9, 0x0

    const/4 v10, 0x0

    const/4 v11, 0x0

    move-object v4, v12

    .line 104
    invoke-virtual/range {v4 .. v11}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v4

    .line 105
    invoke-interface {v4, v3}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    .line 106
    invoke-interface {v4, v2}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    .line 107
    invoke-interface {v4, v1}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    .line 108
    invoke-interface {v4, v0}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    const-string v0, "distance"

    .line 109
    invoke-interface {v4, v0}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    const-string v0, "unique_id"

    .line 110
    invoke-interface {v4, v0}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    .line 111
    invoke-interface {v4}, Landroid/database/Cursor;->close()V

    const-string v5, "distances"

    const/4 v6, 0x0

    const/4 v7, 0x0

    const/4 v8, 0x0

    const/4 v9, 0x0

    const/4 v10, 0x0

    const/4 v11, 0x0

    move-object v4, v12

    .line 113
    invoke-virtual/range {v4 .. v11}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    const-string v5, "tracks"

    const/4 v6, 0x0

    const/4 v7, 0x0

    const/4 v8, 0x0

    const/4 v9, 0x0

    const/4 v10, 0x0

    const/4 v11, 0x0

    move-object v4, v12

    .line 117
    invoke-virtual/range {v4 .. v11}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    const/4 v0, 0x1

    return v0

    :catch_0
    move-exception v0

    .line 120
    invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V

    const/4 v0, 0x0

    return v0
.end method
